<?php

use App\Models\ConfigSale;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateConfigSalesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('config_sales', function (Blueprint $table) {
            $table->id();
            $table->decimal('apple_actual_price', 10, 2)->default(5.00)->comment('苹果实际价格');
            $table->decimal('vip_price', 10, 2)->default(19.90)->comment('会员价格');
            $table->integer('vip_period')->nullable()->default(30)->comment('购买会员天数');
            $table->integer('auto_upgrade_needs_children')->default(6)->comment('升星所需下级');
            $table->integer('auto_upteam_needs_children')->default(10)->comment('升团队所需下级');
            $table->decimal('normal_vip_produce_apple', 10, 2)->default(0.08)->comment("普通会员每日产出苹果");
            $table->decimal('vip_produce_apple', 10, 2)->default(1.00)->comment("星级会员每日产出苹果");
            $table->decimal('vip_one_level_brokage_percent', 10, 2)->default(20.00)->comment("一级团队分佣比例");
            $table->decimal('vip_two_level_brokage_percent', 10, 2)->default(10.00)->comment("二级团队分佣比例");
            $table->decimal('vip_more_level_brokage_percent', 10, 2)->default(0.00)->comment("其他等级团队分佣比例");
            $table->timestamps();
        });

         ConfigSale::create(['apple_actual_price' => '5.00']);
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('config_sales');
    }
}
